package cn.wolfcode.domain;

import cn.wolfcode.enums.NoticeLevelEnum;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@ToString
public class Notice {
    /** */
    private Long id;

    /** */
    private String title;

    /** */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**公告等级*/
    private Integer level;

    /** */
    private String info;


    /**公告状态 */
    private boolean noticeStatus;

    /** 创建人*/
    private Employee employee;

    //员工和 消息的中间表字段
    private EmployeeNotice employeeNotice;

    public String findNoticeLevel(){
        return NoticeLevelEnum.findName(level);
    }

    //数据绑定
    public String toNotice(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);//回显隐藏域需要用
        map.put("noticeStatus",noticeStatus);
        map.put("title",title);
        map.put("info",info);
        //map.put("level",NoticeLevelEnum.values());
        map.put("level",level);
        return JSON.toJSONString(map);
    }
}